package gases.as3.testing
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.DisplayObject;
	import flash.display.Loader;
	import flash.display.LoaderInfo;
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.net.URLRequest;
	
	import gases.as3.librarys.compnents.events.IconCellListEvent;
	import gases.as3.librarys.compnents.resource.MacroResourceManagaers;
	import gases.as3.librarys.compnents.skin.SkinStylesMangaer;
	import gases.as3.librarys.compnents.skin.SkinTransform;
	import gases.as3.librarys.compnents.skin.data.BaseSkin;
	import gases.as3.librarys.compnents.skin.data.IconCellListSkin;
	import gases.as3.librarys.compnents.skin.transform.TransformXML;
	import gases.as3.librarys.compnents.ui.GSkinBox;
	import gases.as3.librarys.compnents.ui.control.IconCellList;
	
	public class TestingIconCellList extends Sprite
	{
		public function TestingIconCellList()
		{
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;
			
			var loader:Loader = new Loader();
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
			loader.load(new URLRequest("assets/iconcelllist.swf"));
		}
		
		private function onComplete(e:Event):void
		{
			
			var swf:DisplayObject = LoaderInfo(e.target).content as DisplayObject;
			MacroResourceManagaers.instance.UIResManager.setUISkinSwf(swf);
			var transform:SkinTransform = new SkinTransform();
			transform.setConfigTransform(new TransformXML());
			transform.resloveSkinConfig(xml);
			var listSkin:BaseSkin = SkinStylesMangaer.instance.getSkinData("icon_list") as BaseSkin;
			var iconBmd:BitmapData = (listSkin as IconCellListSkin).icon as BitmapData;
			
			
			
			var list:IconCellList = new IconCellList(4,6,8,8,30,30);
			this.addChild(list);
			list.skin = listSkin;
			for(var i:int = 0;i< 24;i ++)
			{
				list.updateDrawCell(i,iconBmd,"xx"+i);
			}
			list.addEventListener(IconCellListEvent.CELL_CLICK,click);
			list.addEventListener(IconCellListEvent.CELL_DOUBLE_CLICK,doubleClick);
			list.addEventListener(IconCellListEvent.CELL_DOWN,down);
			list.addEventListener(IconCellListEvent.CELL_OUT,out);
			list.addEventListener(IconCellListEvent.CELL_OVER,over);
			list.addEventListener(IconCellListEvent.CELL_UP,up);
			
		}
		
		private function click(e:IconCellListEvent):void
		{
			trace("click == "+e.data);
		}
		
		private function doubleClick(e:IconCellListEvent):void
		{
			trace("doubleClick == "+e.data);
		}
		
		private function down(e:IconCellListEvent):void
		{
			trace("down == "+e.data);
		}
		
		private function out(e:IconCellListEvent):void
		{
			trace("out == "+e.data);
		}
		
		private function over(e:IconCellListEvent):void
		{
			trace("over == "+e.data);
		}
		
		private function up(e:IconCellListEvent):void
		{
			trace("up == "+e.data);
		}
		
		
		private var xml:XML = <root xmlns:skin="gases.compnents.ui.skin">
													<skin:iconCellList type="iconCellList" scale9_top="5" scale9_left="5" scale9_right="5" scale9_bottom="5" skinname="icon_list" width="60" height="20">
														<styles stylesName="icon" resName="icon"/>
														<styles stylesName="list_bg" resName="list_bg"/>
													</skin:button>
								</root>
	}
}